package com.edu.quartz.task;

import com.edu.framework.websocket.service.PingService;
import com.edu.framework.websocket.service.TerminalService;
import com.edu.system.domain.TTerminal;
import com.edu.system.service.ITTerminalService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * 机器设置消息
 *
 * @author xxxx
 */
@Component("terminalTask")
public class TerminalTask {

    @Resource
    private TerminalService wsTerminalService;
    @Resource
    private ITTerminalService itTerminalService;
    @Resource
    private PingService wsPingService;

    /**
     * 下发开关机设置
     */
    public void shutDownSet() {
        List<TTerminal> t = itTerminalService.selectTTerminalList(new TTerminal());
        Long[] longs = t.stream().map(TTerminal::getId).toArray(Long[]::new);
        wsTerminalService.scheduleShutDown(longs);
    }

    /**
     * 更新机器开机状态
     */
    public void updateStatus(){
        wsPingService.changeStatus();
    }


}
